package ar.uba.fi.tonyvaliente;

import java.util.Iterator;
import java.util.Random;

import ar.uba.fi.tonyvaliente.persistors.IntegerPersistor;
import ar.uba.fi.tonyvaliente.tree.DiskBPlusTree;

public class RepositionTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			DiskBPlusTree<Integer,Integer> tree;
			tree = new DiskBPlusTree<Integer, Integer>(3, "/home/user/bplustree.dat",
					new IntegerPersistor(), new IntegerPersistor());
			
			tree.add(846,648);
			tree.add(464,464);
			tree.add(333,333);
			tree.add(467,764);
			tree.add(121,121);
			tree.add(426,624);
			tree.add(822,228);
			tree.add(967,769);
			tree.add(425,524);
			tree.add(201,102);
			tree.add(299,992);
			tree.add(785,587);
			
			/*Iterator<Integer> it = tree.iterator();
			while (it.hasNext()) {
				Integer k = it.next();
				System.out.println(k + "=" + tree.get(k));
			}*/
			
			tree.close();
			
			tree = new DiskBPlusTree<Integer, Integer>("/home/user/bplustree.dat", false,
					new IntegerPersistor(), new IntegerPersistor());

			System.out.println("846:" + tree.get(846));
			System.out.println("464:" + tree.get(464));
			System.out.println("333:" + tree.get(333));
			System.out.println("467:" + tree.get(467));
			System.out.println("121:" + tree.get(121));
			System.out.println("426:" + tree.get(426));
			System.out.println("822:" + tree.get(822));
			System.out.println("967:" + tree.get(967));
			System.out.println("425:" + tree.get(425));
			System.out.println("201:" + tree.get(201));
			System.out.println("299:" + tree.get(299));
			System.out.println("785:" + tree.get(785));
			
			//tree.forceRepositionNode();
			
			tree.close();
			
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}
